<script setup>

//管理账号
import {ElMessage, ElMessageBox} from "element-plus";
import {ref} from "vue";
import http from "@/request/Http.js";

//id获取当前id
const queryParams = ref({
  token: ''
})

const handleClickDelete = () => {
  ElMessageBox.confirm(
      `你确定要注销账号吗?`,
      {
        confirmButtonText: "确定注销",
        cancelButtonText: "取消",
        type: 'warning'
      }
  ).then(async () => {
    const data = await http.post("delete", queryParams.value)
    if (data.code === 200) {
      ElMessage.success("注销成功!")
      //令token变为空,推到登录页面，未登录不能访问
      sessionStorage.setItem("token", '');
    } else {
      ElMessage.error("删除失败!" + data.msg)
    }
  })
}

</script>

<template>
  <div>
    <p>实名认证</p>
  </div>

  <div>
    <p>邮箱绑定</p>
  </div>

  <div>
    <p>注销账号</p>
    <el-button @click="handleClickDelete">注销</el-button>
  </div>

</template>

<style scoped>

</style>